package com.gitee.wsl.compose.mvi.ui.box

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.gitee.wsl.compose.mvi.component.SlotProjector

class BoxProjector(
    interactor: BoxInteractor = BoxInteractor.Default,
    presenter: BoxPresenter = BoxPresenter.Default
) : SlotProjector<BoxInteractor, BoxPresenter,BoxScope>(interactor, presenter) {

    /*@Composable
    override fun Projection(
        modifier: Modifier,
        content: @Composable BoxScope.() -> Unit
    ) = contextualize(modifier) { combinedModifier, interactor, presenter ->
        Box(
            modifier = combinedModifier,
            contentAlignment = presenter.contentAlignment,
            propagateMinConstraints = presenter.propagateMinConstraints.toBoolean(),
            content = content
        )
    }*/

    @Composable
    override fun body(
        combinedModifier: Modifier,
        interactor: BoxInteractor,
        presenter: BoxPresenter,
        slot: @Composable BoxScope.() -> Unit
    ) {
        Box(
            modifier = combinedModifier,
            contentAlignment = presenter.contentAlignment,
            propagateMinConstraints = presenter.propagateMinConstraints.toBoolean(),
            content = slot
        )
    }
}

@Composable
fun Box(modifier: Modifier = Modifier,
        interactor: BoxInteractor = BoxInteractor.Default,
        presenter: BoxPresenter = BoxPresenter.Default,
        slot: @Composable BoxScope.() -> Unit) = BoxProjector(interactor, presenter)(modifier,slot)